package game.structures;

public class Camera {
	private Entity cameraFocus;
	private Point center;
	private Layer layer;
	
	private final int cameraWidth 	= 800;
	private final int cameraHeight 	= 600;
	
	public Camera(Entity e, Layer l) {
		cameraFocus = e;
		layer = l;
	}
	
	public void update(int delta) {
		center = cameraFocus.getPoint();
		center = new Point(
					Math.min(Math.max(cameraFocus.getPoint().getX(), cameraWidth/2), layer.getRight() - cameraWidth / 2),
					Math.min(Math.max(cameraFocus.getPoint().getY(), cameraHeight/2), layer.getBottom() - cameraHeight / 2)
					);
		
	}
	
	public Point getCenter() { return new Point(center.getX() - cameraWidth / 2, center.getY() - cameraHeight / 2); }
}
